/**
 * Class representing a dvd of a library
 * @author M.T. Segarra, Arnaud Fabre, Ambroise Malric
 * @version 0.0.1
 */
package inf.dvdsManagement;


import inf.exceptions.*;
import inf.mediasManagement.Author;

import java.util.*;


import javax.persistence.*;

@Entity
@DiscriminatorValue("Dvd")
@NamedQuery(name="findAllDvds", query="select d from Dvd d")
public class Dvd extends inf.mediasManagement.Media implements java.io.Serializable {       
   	public Dvd(){};

	/**
	 * Creates a dvd. All parameters should be given
	 *
	 * @param title
	 *            the title of the dvd
	 * @param editionDate
	 *            date of the edition of the dvd
	 * @param isan
	 *            ISAN of the dvd
	 * @throws BadParametersException
	 * @throws MediaExistsException 
	 */
	public Dvd(String title, Calendar editionDate,
			java.lang.String isbnOrIsan, Integer specimens, ArrayList<String> directors) throws BadParametersException, MediaExistsException {
		super(title, editionDate, "Dvd", isbnOrIsan, specimens);

		for(String name : directors){
			this.addAuthor(new Author(name, this));
		}
		
	}

	/**
	 * Test if two dvds are equals
	 * Two dvds are equal if their ISAN is the same
	 * @param dvd the dvd to test
	 * @return a boolean true if dvd is equal to this false if not	
	 */
	@Override
	public boolean equals(Object dvd) {
		if (dvd == null)
			return false;
		Dvd d = (Dvd) dvd;
	
		if (d.isbnOrIsan == isbnOrIsan)
			return true;
	
		return false;
	}
}


